//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.chris.serve;

import com.chris.entity.content;
import com.chris.entity.register;
import com.chris.impl.contentImpl;
import com.chris.impl.registerImpl;
import com.chris.utils.DbConnection;
import com.chris.utils.JsonProcess;
import com.chris.utils.LogUtil;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet({"/paperJournal"})
public class paperJournal extends HttpServlet {
    private final registerImpl dao = new registerImpl();
    private final contentImpl dao2 = new contentImpl();

    public paperJournal() {
    }

    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        PrintWriter writer = resp.getWriter();

        try {
            String content_id = req.getParameter("content_id");
            if (content_id != null) {
                int i = Integer.parseInt(content_id);
                content byContentID = this.dao2.getByContentID(i);
                if (byContentID == null) {
                    writer.print(JsonProcess.respError("content_id不存在"));
                } else {
                    int id2 = byContentID.getJournal_id();
                    register byID = this.dao.getByID(id2);
                    writer.print(JsonProcess.respSuccess("成功", byID));
                }
            } else {
                writer.print(JsonProcess.respError("参数不能为空"));
            }
        } catch (Exception var9) {
            writer.print(JsonProcess.respError("参数错误"));
            LogUtil.log("参数错误",var9);
        }
        DbConnection.endServe();
    }

    public void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        resp.addHeader("Access-Control-Allow-Headers", "*");
    }
}
